package com.streambolics.data;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.InheritanceStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

/**
 * The base class for all definition objects.
 * 
 * Definition objects are the base blocks for storing application setup.
 * Application setup is organized in lists of similarly made objects that define
 * the environment in which the application interacts with the user. Definitions
 * are different from documents in the sense that users do not routinely create
 * new definitions, while documents are created and deleted regularly.
 * 
 * For example, an RSS feed reader would define each RSS feed as a definition
 * (users do not change the list of feeds they follow very often - typical users
 * would not change the list for days or weeks), while each atom in the feed
 * would be a document.
 * 
 * Note that users are themselves definitions.
 * 
 * To simplify ensuring referential integrity constraints, definition objects
 * are never deleted, and so have a "used" property indicating whether they are
 * still in use.
 * 
 * @author Sauron
 * 
 */

@PersistenceCapable(identityType = IdentityType.APPLICATION)
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public class Definition extends NamedSimpleObject
{
    @Persistent
    private Boolean used;

    /**
     * Whether this definition is still actively in use today.
     * 
     * When a definition is not in use, it will not be shown to the user in
     * lists (for example within the choices in a combo box) but they will be
     * shown as usual when displaying a document that still refers to them.
     * 
     * @return
     */

    public Boolean isUsed ()
    {
        return used;
    }

    /**
     * Changes the used status.
     * 
     * @see isUsed
     * 
     * @param used
     */

    public void setUsed (Boolean used)
    {
        this.used = used;
    }
}
